/*
 * @Author: linxun 
 * @Date: 2021-03-06 14:32:25 
 * @Last Modified by: linxun
 * @Last Modified time: 2021-03-06 14:57:03
 * @Description: 数据集详情
 */

import React, { useEffect, useState } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { PageHeader, Card } from 'antd';
import { fetchDataSetDetail } from './service';
import { useIntl, history } from 'umi';
import DetailComponent from './components/Detail';

const Detail = props => {
  const { formatMessage } = useIntl();
  const { id } = props.match.params;
  const [loading, setLoading] = useState(false);
  const [detail, setDetail] = useState({});

  const getDataSetDetail = async () => {
    setLoading(true);
    try {
      const res = await fetchDataSetDetail({ id });
      setLoading(false);
      if (res.code === 0) {
        setDetail(res.data);
      }
    } catch (err) {
      console.log(err);
    }
  };

  useEffect(() => {
    getDataSetDetail();
  }, []);

  return (
    <PageHeaderWrapper title={false}>
      <PageHeader
        ghost={false}
        onBack={history.goBack}
        title={formatMessage({ id: 'menu.dataManage.dataSetDetail' })}
      ></PageHeader>
      <Card>
        <DetailComponent loading={loading} detail={detail} />
      </Card>
    </PageHeaderWrapper>
  )
}

export default Detail;